Skip to main content
Version: Next

Security Best Practices

The current security setup is robust, with Docker on Ubuntu Server, a restricted firewall (ports 80, 22, 443), 2FA on Digital Ocean, Fail2Ban, and hardened SSH. Below are tailored recommendations to maintain and enhance security:

Authentication and Authorization

  • SSH is secured with key-based authentication (PasswordAuthentication no in /etc/ssh/sshd_config) and root login disabled (PermitRootLogin no).
  • Digital Ocean console uses 2FA for all team members—ensure this is enforced for new users.
  • For the application, implement OAuth 2.0 or JWT tokens for API authentication; consider adding MFA for admin users.

Data Protection

  • Use Docker secrets to securely inject environment variables (e.g., database credentials) into containers.
  • TLS 1.3 is enforced on ports 80/443 (e.g., via Let’s Encrypt with Certbot); renew certificates automatically with a cron job.
  • Database backups are stored in Digital Ocean Spaces or AWS S3—ensure they’re encrypted with server-side encryption (SSE).

Network Security

  • Digital Ocean firewall allow traffic only to ports 80, 22, and 443.
  • Fail2Ban is active to block brute-force SSH attempts—monitor its logs (/var/log/fail2ban.log) for suspicious activity.
  • Use Docker’s --network flag to isolate containers and prevent unintended internal exposure.

Container Security

  • Trivy scans Docker images for vulnerabilities during GitHub Actions CI—fail builds if critical issues are detected (e.g., --exit-code 1 --severity CRITICAL).
  • Run containers as non-root users (add USER appuser in Dockerfile after creating a non-root user).
  • Regularly update the Ubuntu base image and Docker engine (apt update && apt upgrade in a maintenance window).

Incident Response

  • Review Digital Ocean security notifications and Fail2Ban logs for potential threats.
  • Enable audit logging (e.g., via auditd or SigNoz) to track system and application changes.
  • Document an incident response plan (e.g., who to notify, how to restore from backups).